package com.cnap.db.entity;

import com.cnap.model.strategy.MicroServiceVOV2;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.time.LocalDateTime;
import java.util.Arrays;

/**
 * 拆分的微服务信息
 *
 * @author xc
 **/
public class MicroServicePO {
    // id
    private String id;
    // 微服务名称
    private String microServiceName;
    // 路径
    private String path;
    // 框架
    private String framework;
    // 大小
    private String size;
    // 应用id
    private String applicationId;
    // yaml
    private String yaml;
    // 镜像名称
    private String imageName;
    // 状态
    private int status;
    // 用户名称
    private String userName;
    // 应用名称
    private String applicationName;
    // 更新时间
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;
    // deployment名称
    private String deploymentName;
    // 命名空间
    private String namespace;
    // 微服务名称
    private String serviceName;
    // 分类
    private String category;
    // 二级分类，动态训练 静态训练，Batchsieze-8，Batchsieze-16，Batchsieze-32，Batchsieze-64
    private String type;

    /**
     * get
     *
     * @return Type
     */
    public String getType() {
        return type;
    }

    /**
     * set
     *
     * @param type type
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * get
     *
     * @return Id
     */
    public String getId() {
        return id;
    }

    /**
     * set
     *
     * @param id id
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * get
     *
     * @return MicroServiceName
     */
    public String getMicroServiceName() {
        return microServiceName;
    }

    /**
     * set
     *
     * @param microServiceName microServiceName
     */
    public void setMicroServiceName(String microServiceName) {
        this.microServiceName = microServiceName;
    }

    /**
     * get
     *
     * @return Path
     */
    public String getPath() {
        return path;
    }

    /**
     * set
     *
     * @param path path
     */
    public void setPath(String path) {
        this.path = path;
    }

    /**
     * get
     *
     * @return Framework
     */
    public String getFramework() {
        return framework;
    }

    /**
     * set
     *
     * @param framework framework
     */
    public void setFramework(String framework) {
        this.framework = framework;
    }

    /**
     * get
     *
     * @return Size
     */
    public String getSize() {
        return size;
    }

    /**
     * set
     *
     * @param size size
     */
    public void setSize(String size) {
        this.size = size;
    }

    /**
     * get
     *
     * @return ApplicationId
     */
    public String getApplicationId() {
        return applicationId;
    }

    /**
     * set
     *
     * @param applicationId applicationId
     */
    public void setApplicationId(String applicationId) {
        this.applicationId = applicationId;
    }

    /**
     * get
     *
     * @return Yaml
     */
    public String getYaml() {
        return yaml;
    }

    /**
     * set
     *
     * @param yaml yaml
     */
    public void setYaml(String yaml) {
        this.yaml = yaml;
    }

    /**
     * get
     *
     * @return ImageName
     */
    public String getImageName() {
        return imageName;
    }

    /**
     * set
     *
     * @param imageName imageName
     */
    public void setImageName(String imageName) {
        this.imageName = imageName;
    }

    /**
     * get
     *
     * @return Status
     */
    public int getStatus() {
        return status;
    }

    /**
     * set
     *
     * @param status status
     */
    public void setStatus(int status) {
        this.status = status;
    }

    /**
     * get
     *
     * @return UserName
     */
    public String getUserName() {
        return userName;
    }

    /**
     * set
     *
     * @param userName userName
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * get
     *
     * @return ApplicationName
     */
    public String getApplicationName() {
        return applicationName;
    }

    /**
     * set
     *
     * @param applicationName applicationName
     */
    public void setApplicationName(String applicationName) {
        this.applicationName = applicationName;
    }

    /**
     * get
     *
     * @return UpdateTime
     */
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    /**
     * set
     *
     * @param updateTime updateTime
     */
    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * get
     *
     * @return DeploymentName
     */
    public String getDeploymentName() {
        return deploymentName;
    }

    /**
     * set
     *
     * @param deploymentName deploymentName
     */
    public void setDeploymentName(String deploymentName) {
        this.deploymentName = deploymentName;
    }

    /**
     * get
     *
     * @return Namespace
     */
    public String getNamespace() {
        return namespace;
    }

    /**
     * set
     *
     * @param namespace namespace
     */
    public void setNamespace(String namespace) {
        this.namespace = namespace;
    }

    /**
     * get
     *
     * @return ServiceName
     */
    public String getServiceName() {
        return serviceName;
    }

    /**
     * set
     *
     * @param serviceName serviceName
     */
    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    /**
     * get
     *
     * @return Category
     */
    public String getCategory() {
        return category;
    }

    /**
     * set
     *
     * @param category category
     */
    public void setCategory(String category) {
        this.category = category;
    }

    /**
     * 转换成VO
     *
     * @return vo
     */
    public MicroServiceVOV2 toVOV2() {
        MicroServiceVOV2 microServiceVO = new MicroServiceVOV2();
        microServiceVO.setSvcId(this.id);
        microServiceVO.setApplicationId(this.getApplicationId());
        microServiceVO.setApplicationName(this.getApplicationName());
        microServiceVO.setSvcName(this.getMicroServiceName());
        microServiceVO.setSize(this.getSize());
        microServiceVO.setStatus(String.valueOf(this.getStatus()));
        microServiceVO.setProvider(this.getUserName());

        microServiceVO.setPaths(Arrays.asList(this.getPath().split(",")));
        microServiceVO.setUpdateTime(this.getUpdateTime());
        microServiceVO.setCategory(this.getCategory());

        return microServiceVO;
    }
}
